package com.awb.rabbitmqdemo.topics;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicsConfig {

    public static final String TOPICS_EXCHANGE = "topic_exchange";

    public static final String TOPICS_QUEUE_INFO = "topic.queue.info";
    
    public static final String TOPICS_QUEUE_DEBUG = "topic.queue.debug";
    
    public static final String TOPICS_QUEUE_ERROR = "topic.queue.error";
    
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(TOPICS_EXCHANGE);
    }

    @Bean
    public Queue queueInfo(){
        return new Queue(TOPICS_QUEUE_INFO);
    }

    @Bean
    public Queue queueDebug(){
        return new Queue(TOPICS_QUEUE_DEBUG);
    }

    @Bean
    public Queue queueError(){
        return new Queue(TOPICS_QUEUE_ERROR);
    }
    
    @Bean
    public Binding bindingInfo(){
        return BindingBuilder.bind(queueInfo()).to(topicExchange()).with("*.*.info");
    }

    @Bean
    public Binding bindingError(){
        return BindingBuilder.bind(queueError()).to(topicExchange()).with("*.*.error");
    }
    
    
    
    
}
